package com.skivingcloud.report.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.skivingcloud.report.entity.ReportOnlineTpl;
import com.skivingcloud.report.mapper.ReportOnlineTplMapper;
import com.skivingcloud.report.service.ReportOnlineTplService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.skivingcloud.common.utils.PageParameter;

/**
 * 协同文档基本信息表 服务层实现。
 *
 * @author skivingcloud
 * @since 2024-11-07
 */
@Service
public class ReportOnlineTplServiceImpl extends ServiceImpl<ReportOnlineTplMapper, ReportOnlineTpl> implements ReportOnlineTplService {

    /**
     * 分页查询协同文档基本信息表
     *
     * @param parameter 查询参数
     * @return 分页查询结果
     */
    @Override
    public Page<ReportOnlineTpl> queryByPage(PageParameter<ReportOnlineTpl> parameter){
        Page<ReportOnlineTpl> page = new Page<>(parameter.getPage(), parameter.getPageSize());
        QueryWrapper queryWrapper = QueryWrapper.create();
        if (parameter.getParam() != null) {
            //查询条件
            if (StringUtils.isNoneBlank(parameter.getParam().getId())) {
                queryWrapper.and(ReportOnlineTpl::getId).like(parameter.getParam().getId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getTenantId())) {
                queryWrapper.and(ReportOnlineTpl::getTenantId).like(parameter.getParam().getTenantId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getReportId())) {
                queryWrapper.and(ReportOnlineTpl::getReportId).like(parameter.getParam().getReportId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getTplName())) {
                queryWrapper.and(ReportOnlineTpl::getTplName).like(parameter.getParam().getTplName());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getListId())) {
                queryWrapper.and(ReportOnlineTpl::getListId).like(parameter.getParam().getListId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getViewAuth())) {
                queryWrapper.and(ReportOnlineTpl::getViewAuth).like(parameter.getParam().getViewAuth());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDesignPwd())) {
                queryWrapper.and(ReportOnlineTpl::getDesignPwd).like(parameter.getParam().getDesignPwd());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getExportEncrypt())) {
                queryWrapper.and(ReportOnlineTpl::getExportEncrypt).like(parameter.getParam().getExportEncrypt());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getSource())) {
                queryWrapper.and(ReportOnlineTpl::getSource).like(parameter.getParam().getSource());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDataLoadType())) {
                queryWrapper.and(ReportOnlineTpl::getDataLoadType).like(parameter.getParam().getDataLoadType());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getCreator())) {
                queryWrapper.and(ReportOnlineTpl::getCreator).like(parameter.getParam().getCreator());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getUpdater())) {
                queryWrapper.and(ReportOnlineTpl::getUpdater).like(parameter.getParam().getUpdater());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDelFlag())) {
                queryWrapper.and(ReportOnlineTpl::getDelFlag).like(parameter.getParam().getDelFlag());
            }
        }
        return this.page(page, queryWrapper);
    }
}
